package com.baichang.taoshunda.controller.mobile.business;

import com.baichang.framework.controller.BaseMobileController;
import com.baichang.framework.controller.IService;
import com.baichang.framework.excelption.ServiceException;
import com.baichang.taoshunda.controller.ControllerConstants;
import com.baichang.taoshunda.service.CompanyBalanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping(ControllerConstants.BUSSINESSBALANCE)
public class BussinessBanlanceMController extends BaseMobileController {

    @Autowired
    private CompanyBalanceService companyBalanceService;

    /**
     * 查看商家账单明细
     *
     * @param request
     * @param response
     */
    @RequestMapping("/findBussinessBills")
    public void findBussinessBills(HttpServletRequest request, HttpServletResponse response) {
        initEncode(request, response, new IService() {
            @Override
            public Object init(HttpServletRequest request, HttpServletResponse response, String json) throws ServiceException {
                Integer bussId = getInt(json, "bussId", 0);
                Integer nowPage = getInt(json, "nowPage", 1);
                Integer pageSize = getInt(json, "pageSize", 20);
                String startDate = getString(json, "startDate", "");
                String endDate = getString(json, "endDate", "");
                return companyBalanceService.findBussinessBills(bussId, startDate, endDate,nowPage,pageSize);
            }
        });
    }

    /**
     * 查看商家钱包信息
     *
     * @param request
     * @param response
     */
    @RequestMapping("/findBussinessWallet")
    public void findBussinessWallet(HttpServletRequest request, HttpServletResponse response) {
        initEncode(request, response, new IService() {
            @Override
            public Object init(HttpServletRequest request, HttpServletResponse response, String json) throws ServiceException {
                Integer bussId = getInt(json, "bussId", 0);
                return companyBalanceService.findBussinessWallet(bussId);
            }
        });
    }


}
